﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Killboard.Models.ekbKill>>" %>



<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<%
    System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("en-US");
    int week = myCI.Calendar.GetWeekOfYear( DateTime.Now.ToUniversalTime(), System.Globalization.CalendarWeekRule.FirstFourDayWeek, 
    System.DayOfWeek.Sunday );
    

//Html.Encode(System.Globalization.Calendar System.DateTime.Now.ToUniversalTime(). 

%>

<script type="text/javascript">

function DoNav(theUrl) {
    
    document.location.href = theUrl;
}
  
</script>
    
    <h1>
        Week <%=Html.Encode(week) %>
    </h1>
    <% Html.RenderPartial("KillStatsByShip", ViewData["killsByShip"]); %>
    <div style="clear:both">
    <h1 style="padding-top: 30px;">Most Recent 20 Kills</h1>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td>    
    <%
        string prevDate = string.Format("{0:yyyyMMdd}", DateTime.MinValue);
        bool firstTime = true;
        
        foreach (var kill in Model)
        {
            string thisDate = string.Format("{0:yyyyMMdd}", kill.KillTimeUTC);

            if (thisDate != prevDate)
            {
                if (!firstTime)
                {
                    Response.Write("</table>");
                }
                else
                {
                    firstTime = false;
                }
                
                prevDate = thisDate;
%>
<div class="showDate"><%=Html.Encode(string.Format("{0:D}", kill.KillTimeUTC)) %></div><p></p>
        <table class="killSummary" border="0" cellpadding="0" cellspacing="0">
            <tr id="<%=Html.Encode(kill.__ID) %>">
                <th style="text-align: center" colspan="2">Ship Type</th>
                <th>Victim</th>
                <th>Final Blow</th>
                <th style="text-align: center">System</th>
                <th style="text-align: center">Inv.</th>
                <th style="text-align: center">Time</th>
                <th>&nbsp;</th>
            </tr>
        <%                
                    }

                    Html.RenderPartial("KillSummary", kill);            
                }
                 %>
         </table>
    </td>
    <td style="min-width:2px">&nbsp;</td>
    <td style="width:128px" valign="top"><br /><br /><br /><br />
                     <%
                     Killboard.Models.KillRepository repo = new Killboard.Models.KillRepository();
                     
                     Html.RenderPartial("PilotStats", repo.GetTopKillersForWeek()); %>
                     <p></p>
                     <%Html.RenderPartial("PilotStatsLosers", repo.GetTopLosersForWeek()); %>
    </td>
    </tr>
</table>
</asp:Content>
